// Copyright (C) Kumo inc. and its affiliates.
// Author: Jeff.li lijippy@163.com
// All rights reserved.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published
// by the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program.  If not, see <https://www.gnu.org/licenses/>.
//


#pragma once

#include <cstdint>
#include <string_view>

namespace kumo::pollux::common {
    /// Defines a disk region to read.
    struct Region {
        uint64_t offset;
        uint64_t length;
        /// Optional label used by lower layers for cache warm up.
        std::string_view label;

        Region(uint64_t offset = 0, uint64_t length = 0, std::string_view label = {})
            : offset{offset}, length{length}, label{label} {
        }

        bool operator<(const Region &other) const {
            return offset < other.offset ||
                   (offset == other.offset && length < other.length);
        }
    };
} // namespace kumo::pollux::common
